<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        window.onload = function() {

            // 箭头函数的作用  就是将this 如果指向了window-->改成当前操作对象
            var oBtn = document.getElementById('btn')

            // 点击按钮 等待一秒钟 ,再弹出提示框

            oBtn.onclick = function() {
                console.log(this)
                setTimeout(() => {
                    console.log(this)
                    alert('箭头函数')
                    this.style.backgroundColor = 'red'
                }, 1000)


            }



        }
    </script>
</head>

<body>
    <button id="btn">点击按钮</button>

</body>

</html>